package com.bsh.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bsh.api.ApiUtils;
import com.bsh.mybatis.model.MerchantImg;
import com.bsh.repository.DaoMerchantImg;
import com.bsh.service.MerchantImgService;
@Service
@Transactional
public class MerchantImgServiceImpl implements MerchantImgService {

	
	@Autowired
	DaoMerchantImg  merchantImgDao;
	
	
	@Override
	public Integer addMerchantImg(MerchantImg merchantImg) {
		return merchantImgDao.insert(merchantImg);
	}


	@Override
	public Integer updateMerchantImgUrl(MerchantImg merchantImg) {
		MerchantImg record=merchantImgDao.selectByPrimaryKey(merchantImg.getId());
		int res=-1;
		if(ApiUtils.objIsEmpty(record)){
			res=merchantImgDao.insert(record);
		}else{
			record.setUrl(merchantImg.getUrl());
			res=merchantImgDao.updateByPrimaryKey(record);
		}
		return res;
	}


	
}
